import axios from "axios";

// todo 1.
export const FE_HOME_URL = 'http://localhost:8082/#/';
// export const FE_HOME_URL = 'https://txwechat.sinosig.com/sunshineweb/lifepolifyfe/#/';
// export const FE_HOME_URL = 'https://grpwechat.sinosig.com/sunshineweb/lifepolifyfe/#/';

// 基本配置
const service = axios.create({
    // todo
    // baseURL: 'http://localhost:8083',
    // baseURL: "http://10.136.96.119:8081",
    baseURL: "http://localhost:8081",
    // baseURL: "http://10.9.139.14:8081",
    // // todo 2.
    // baseURL: "https://txwechat.sinosig.com",
    // 生产
    // baseURL: "https://grpwechat.sinosig.com",
    timeout: 5000,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
    },
    // orginalData:true
});

// 请求拦截器
service.interceptors.request.use(
    (config) => {
        return config;
    },
    (error) => {
        Promise.reject(error);
    }
);

// 响应拦截器
service.interceptors.response.use(
    (response) => {
        return response.data;
    },
    (error) => {
        return Promise.reject(new Error(error.response.data));
    }
);

export default service;
